package com.zzvcom.sms.entity;

import com.zzvcom.sms.exception.AppParamException;

import java.math.BigDecimal;
import java.util.Map;

public abstract class AppLocationMopedParam extends AppMopedParam {
    private final BigDecimal longitude;
    private final BigDecimal latitude;

    public BigDecimal getLongitude() {
        return longitude;
    }

    public BigDecimal getLatitude() {
        return latitude;
    }

    protected AppLocationMopedParam(String appKey, String companyCode, String licensePlateNumber,
                                    String rfidPlateNumber, String vin, BigDecimal longitude
            , BigDecimal latitude, Long timestamp, String nonce) {
        super(appKey, companyCode, licensePlateNumber, rfidPlateNumber, vin, timestamp, nonce);
        if (longitude == null) {
            throw new AppParamException("经度参数不存在");
        }
        if (latitude == null) {
            throw new AppParamException("纬度参数不存在");
        }
        this.longitude = longitude;
        this.latitude = latitude;
    }

    @Override
    public Map<String, String> toMap() {
        Map<String, String> treeMap = super.toMap();
        treeMap.put("longitude", this.getLongitude().toString());
        treeMap.put("latitude", this.getLatitude().toString());
        return treeMap;
    }
}